<?php
session_start();
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
if(!isset($_SESSION['name'])||empty ( $_SESSION['name'])){
     header('Location: login.php');
}
include '../../functions.php';

?>
 <link rel="stylesheet" href="css/calendar.css">
<link rel="stylesheet" href="css/style.css">
<script language="JavaScript" src="js/calendar_db.js" ></script>
<script src="jquery-1.5.1.js"></script>
<script src="js/myfav.js"></script>

<div>
<?php
if(!empty ($searchTitle))
{
    echo "you search for $searchTitle";
}
?>
</div>
<a href="upload.php">ADD</a>&nbsp;&nbsp;&nbsp;<a href="view.php">show all</a>
<table cellpadding="10" border="1" >

    <tr><td>FileName</td><td>Owner</td><td>UploadAt</td><td>Dolwnload</td><td>delete</td></tr>
    <?php
        include 'connect.php';

        $itemSet=  mysql_query("select files.id,filename,name,uploadDate,code
                                from users,files
                                where users.id=files.user_id
                                and files.id in (select file_id
                                              from favorites
                                              where user_id=$_SESSION[id]
                                                    )");
       

        while($item=mysql_fetch_array($itemSet))
        {
            $downloadLink="<a href=\"mmm/$item[code]\">download</a>";
            echo "<tr><td>$item[filename]</td><td>$item[name]</td><td>$item[uploadDate]</td><td>$downloadLink</td><td><span id=\"$item[id]\">DELETE</span></td></tr> ";
        }
    ?>
</table>